package c09_list_method;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        //1.创建集合
        List<String> manStar = new ArrayList<>();
//2.添加模拟数据
        manStar.add("宝强");
        manStar.add("李晨");
        manStar.add("邓超");
        manStar.add("陈赫");
        manStar.add("王宝强");

//3. 使用四种方式遍历List集合
        //lambda
        manStar.forEach(    s -> System.out.println(s));
        //集合。fori
        for (int i = 0; i < manStar.size(); i++) {
            System.out.println(manStar.get(i));
        }
        //iteractor
        Iterator<String>iterator=manStar.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
        //增强for
        for (String s : manStar) {
            System.out.println(s);
        }
    }
}
